<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>Document</title>
    <script src="./vue.js"></script>
    <script src="./vue-router.js"></script>
  </head>
  <body>
    <div id="app">
      <h1>我是根组件</h1>

      <router-link to="/books">books</router-link>
      <router-link to="/news">news</router-link>
      <router-link to="/user">User</router-link>

      <hr />

      <a href="#/books">books</a>
      <a href="#/news">news</a>

      <hr />

      <router-view></router-view>
    </div>

    <script>
        const Books = {
            template:'<h1>books组件</h1>'
        }

        const News = {
            template:'<h1>news组件</h1>'
        }

        const User={
            mouted() {
                console.log(this.$route);
            },

            template:'<h1>User 组件-----{{$route.params.id}} --------{{$route.params.name}}</h1>'
        }

        let myRouter = new VueRouter({
          routes:[{path:'/user/:id/:name',component:User},{path:'/books',component:Books},{path:'/news',component:News}]
        })

      var vm = new Vue({
        el:'#app',
        router: myRouter
       });
    </script>
  </body>
</html>
